import request from '@utils/request'
import { APIParams, APIResult } from '@utils/request/type'
import { VariableDataVO } from '@/api/entity/history'
import { AxiosRequestConfig } from 'axios'
import { ServerEnum } from '@/api/enum/server'

/**
 * 获取历史数据
 * @param params
 * @param config
 */
export const getVariableHistoryByDateAPI = (params: {
  // 结束时间
  endTime?: string
  // 开始时间
  startTime?: string
  // 设备主键id
  tableName?: string
  // 变量id
  variableIds?: string[]
}, config?: AxiosRequestConfig<any>) => request.post<APIResult<VariableDataVO[]>>(ServerEnum.DataGatherer + '/dataOperation/getDataByVariableAndTime', params, config)

/**
 * 获取设备历史数据
 * @param params
 */
export const getDeviceHistoryByDateAPI = (params: APIParams.Page<{
  // 结束时间
  endTime?: string
  // 开始时间
  startTime?: string
  // 设备主键id
  tableName?: string
}>) => request.post<APIResult.Page<VariableDataVO[]>>(ServerEnum.DataGatherer + '/dataOperation/getDataByDeviceIdAndTime', params)

/**
 * 删除历史数据
 * @param params
 */
export const deleteDeviceHistoryByDateAPI = (params: {
  // 结束时间
  endTime?: string
  // 开始时间
  startTime?: string
  // 设备主键id
  tableName?: string
}) => request.post(ServerEnum.DataGatherer + '/dataOperation/delDataByTime', params)
